﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CarDriver
{
    public class message
    {
        private List<byte> data = new List<byte>();
        public int id;

        public message(int id, byte[] body)
        {
            this.id = id;
            data.InsertRange(0, body);
        }

        public int size()
        {
            return data.Count;
        }

        public void encode_header()
        {
            data.InsertRange(0, Encoding.UTF8.GetBytes(size().ToString("X3")));
            data.InsertRange(0, Encoding.UTF8.GetBytes(id.ToString("X")));
        }

        public byte[] get()
        {
            return data.ToArray();
        }
    }
}
